﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _09_1对多.M_1对1
{
    public class DeliveryConfig : IEntityTypeConfiguration<Delivery>
    {
        public void Configure(EntityTypeBuilder<Delivery> builder)
        {
            builder.ToTable("T_Deliverys");
            // 指定外键
            builder.HasOne<Order>(o => o.Order).WithOne(o => o.Delivery).HasForeignKey<Delivery>(d => d.OrderId);
        }
    }
}
